<template>
  <!-- 培训情况 -->
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      v-show="showSearch"
      :inline="true"
      label-width="80px"
    >
      <el-form-item label="培训类型" prop="category">
        <el-select
          v-model="queryParams.category"
          placeholder="培训类型"
          clearable
          size="small"
          style="width: 240px"
          @change="handleQuery"
        >
          <el-option
            v-for="item in cateOptions"
            :key="item.id"
            :label="item.label"
            :value="item.id"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="培训班组" prop="shiftId">
        <el-select
          v-model="queryParams.shiftId"
          placeholder="培训班组"
          clearable
          size="small"
          style="width: 240px"
          @change="handleQuery"
        >
          <el-option
            v-for="dict in deptOptions"
            :key="dict.theid"
            :label="dict.title"
            :value="dict.theid"
          />
        </el-select>
      </el-form-item>
      <!-- <el-form-item label="培训班组" prop="curriculumType">
        <el-select
          v-model="queryParams.status"
          placeholder="培训班组"
          clearable
          size="small"
          style="width: 240px"
        >
        <el-option
            v-for="item in deptOptions"
            :key="item.id"
            :label="item.label"
            :value="item.id"
          /> 
       </el-select>
      </el-form-item> -->
      <el-form-item label="培训时间">
        <el-date-picker
          v-model="dateRange"
          size="small"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          @change="selectTime"
        ></el-date-picker>
      </el-form-item>
      <el-form-item label="关键字" prop="keywords">
        <el-input
          v-model="queryParams.keywords"
          placeholder="请输入培训标题"
          clearable
          style="width: 240px"
          @keyup.enter.native="handleQuery"
          size="small"
        />
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          v-hasPermi="['31460']"
          @click="handleExport"
          >导出培训记录</el-button
        >
      </el-col>
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>
    <el-table v-loading="loading" :data="tableList" :border="true">
      <el-table-column label="培训类型" prop="typeVal" align="center" />
      <!-- <el-table-column label="课程任务ID" prop="createTime" align="center" /> -->
      <el-table-column label="课程名称" prop="title" align="center" />
      <el-table-column label="课程课时" prop="classHours" align="center" />
      <el-table-column
        label="班组名称"
        prop="shift"
        align="center"
        :show-overflow-tooltip="true"
      >
        <template slot-scope="scope">
          <span @click="handleTeam(scope.row)" class="active">
            {{ scope.row.shift }}
          </span>
        </template>
      </el-table-column>
      <el-table-column label="培训人数" prop="personnelNum" align="center" />
      <el-table-column label="考试名称" prop="examTask" align="center" />
      <el-table-column label="考试状态" align="center" key="examination">
        <template slot-scope="scope">
          <span v-if="scope.row.examination === 0">无</span>
          <span v-if="scope.row.examination === 1">有</span>
        </template>
      </el-table-column>
      <el-table-column
        label="培训时间"
        prop="startTime"
        align="center"
        width="170"
      >
        <template slot-scope="scope">
          <!-- <span>{{ scope.row.startTime }} —— {{ scope.row.endTime }}</span> -->
          <span>{{ scope.row.startTime }} </span>
        </template>
      </el-table-column>
      <el-table-column label="课程状态" prop="theState" align="center">
        <template slot-scope="scope">
          <span v-if="scope.row.theState === 1">正在上课</span>
          <span v-if="scope.row.theState === 2">等待上课</span>
          <span v-if="scope.row.theState === 3">已结束</span>
          <span v-if="scope.row.theState === 4">异常数据</span>
        </template>
      </el-table-column>
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
        fixed="right"
        width="120"
      >
        <template slot-scope="scope">
          <!-- <el-button
            size="mini"
            type="text"
            @click="handleUpdate(scope.row)"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            @click="handleDelete(scope.row)"
          >删除</el-button> -->
          <el-button
            size="mini"
            type="text"
            @click="testStat(scope.row)"
            v-if="scope.row.examination === 1"
            >考试统计</el-button
          >
          <el-button size="mini" type="text" @click="handleCheck(scope.row)"
            >审核</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.currentPage"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 点击培训班组，显示考试人员信息 -->
    <el-dialog
      title="考试人员信息"
      :visible.sync="openTeam"
      width="800px"
      append-to-body
    >
      <el-row :gutter="10" class="mb8">
        <el-col :span="1.5">
          <el-button
            type="warning"
            plain
            icon="el-icon-download"
            size="mini"
            @click="handleExport"
            >导出试卷</el-button
          >
        </el-col>
        <el-col :span="1.5">
          <el-button
            type="warning"
            plain
            icon="el-icon-download"
            size="mini"
            @click="handleExport"
            >导出试题</el-button
          >
        </el-col>
      </el-row>

      <el-table
        v-loading="loading2"
        :data="crewOptions"
        :border="true"
        max-height="600px"
      >
        <!-- <el-table-column label="人员ID" prop="certCode" type="index" align="center" /> -->
        <el-table-column
          label="部门"
          prop="department"
          align="center"
          :show-overflow-tooltip="true"
          v-if="ispeople == 1"
        />
        <el-table-column
          label="姓名"
          prop="fullName"
          align="center"
          :show-overflow-tooltip="true"
        />
        <el-table-column
          label="工作单位"
          prop="workUnit"
          align="center"
          :show-overflow-tooltip="true"
          v-if="ispeople == 2"
        />
        <el-table-column
          label="工种"
          prop="workType"
          align="center"
          :show-overflow-tooltip="true"
        />
        <el-table-column
          label="岗位"
          prop="post"
          align="center"
          :show-overflow-tooltip="true"
          v-if="ispeople == 1"
        />
        <el-table-column
          label="培训时长"
          prop="trainDuration"
          align="center"
          :show-overflow-tooltip="true"
        />
        <el-table-column
          label="签到时间"
          prop="signinTime"
          align="center"
          :show-overflow-tooltip="true"
        />
        <el-table-column
          label="签退时间"
          prop="signoutTime"
          align="center"
          :show-overflow-tooltip="true"
        />
        <el-table-column
          label="考试成绩"
          prop="score"
          align="center"
          :show-overflow-tooltip="true"
          v-if="isexam == 1"
        />
        <el-table-column label="培训结果" align="center" key="reviewStatus">
          <template slot-scope="scope">
            <span v-if="scope.row.reviewStatus === 0">待批阅</span>
            <span v-if="scope.row.reviewStatus === 1">合格</span>
            <span v-if="scope.row.reviewStatus === 2">不合格</span>
          </template>
        </el-table-column>
        <el-table-column
          label="操作"
          align="center"
          class-name="small-padding fixed-width"
          fixed="right"
          width="100"
        >
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              @click="seeTestPaper(scope.row)"
              v-if="isexam == 1"
              >查看试卷</el-button
            >
          </template>
        </el-table-column>
      </el-table>

      <pagination
        v-show="crewtotal > 0"
        :total="crewtotal"
        :page.sync="peoplequeryParams.currentPage"
        :limit.sync="peoplequeryParams.pageSize"
        @pagination="getCrews"
      />
    </el-dialog>

    <!-- 点击考试统计，显示当前考试统计信息 -->
    <el-dialog
      title="当前考试统计信息"
      :visible.sync="openTestStat"
      width="800px"
      append-to-body
    >
      <el-form
        ref="testStatForm"
        :model="testStatForm"
        label-width="80px"
        :inline="true"
      >
        <el-form-item label="培训人数" prop="personnelNum">
          <el-input v-model="testStatForm.personnelNum" disabled />
        </el-form-item>
        <el-form-item label="及格人数" prop="passNum">
          <el-input v-model="testStatForm.passNum" disabled />
        </el-form-item>
        <el-form-item label="及格率" prop="passRate">
          <el-input v-model="testStatForm.passRate" disabled />
        </el-form-item>
      </el-form>
    </el-dialog>

    <!-- 点击培训审核，显示考试人员信息 -->
    <el-dialog
      title="考试人员信息"
      :visible.sync="checkOpen"
      width="800px"
      append-to-body
    >
      <el-row
        :gutter="10"
        class="mb8"
        style="display: flex; align-items: center"
      >
        <el-col :span="1.5">
          <el-form label-width="80px">
            <el-form-item
              label="审核结果"
              prop="typeId"
              style="margin-bottom: 0; margin-right: 20px"
            >
              <el-radio-group v-model="Status">
                <el-radio :label="1" style="margin-right: 20px">合格</el-radio>
                <el-radio :label="2">不合格</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-form>
        </el-col>
        <el-col :span="1.5">
          <el-button
            type="warning"
            plain
            icon="el-icon-download"
            size="mini"
            :disabled="multiple"
            @click="handleMultiCheck"
            >批量审核</el-button
          >
        </el-col>
        <el-col :span="1.5">
          <el-button
            type="warning"
            plain
            icon="el-icon-download"
            size="mini"
            :disabled="multiple"
            >导出名单</el-button
          >
          <!-- @click="handleMultiCheck" -->
        </el-col>
      </el-row>

      <el-table
        v-loading="loading2"
        :data="ExamineOptions"
        @selection-change="handleSelectionChange"
        :border="true"
        max-height="600px"
      >
        <el-table-column type="selection" width="55" align="center" />
        <el-table-column
          label="部门"
          prop="department"
          align="center"
          :show-overflow-tooltip="true"
          v-if="ispeople == 1"
        />
        <el-table-column
          label="姓名"
          prop="fullName"
          align="center"
          :show-overflow-tooltip="true"
        />
        <el-table-column
          label="工作单位"
          prop="workUnit"
          align="center"
          :show-overflow-tooltip="true"
          v-if="ispeople == 2"
        />
        <el-table-column
          label="工种"
          prop="workType"
          align="center"
          :show-overflow-tooltip="true"
        />
        <el-table-column
          label="岗位"
          prop="post"
          align="center"
          :show-overflow-tooltip="true"
          v-if="ispeople == 1"
        />
        <el-table-column
          label="培训时长"
          prop="trainDuration"
          align="center"
          :show-overflow-tooltip="true"
        />
        <el-table-column
          label="实际学习时长"
          prop="actualStudyDuration"
          align="center"
          :show-overflow-tooltip="true"
        />
        <el-table-column
          label="签到时间"
          prop="signinTime"
          align="center"
          :show-overflow-tooltip="true"
        />
        <el-table-column
          label="签退时间"
          prop="signoutTime"
          align="center"
          :show-overflow-tooltip="true"
        />
        <el-table-column
          label="考试成绩"
          prop="score"
          align="center"
          :show-overflow-tooltip="true"
          v-if="isexam == 1"
        />
        <el-table-column
          label="是否及格"
          align="center"
          key="pass"
          v-if="isexam == 1"
        >
          <template slot-scope="scope">
            <span v-if="scope.row.pass === 0">未阅卷</span>
            <span v-if="scope.row.pass === 1">合格</span>
            <span v-if="scope.row.pass === 2">不合格</span>
          </template>
        </el-table-column>
        <el-table-column label="审核状态" align="center" key="reviewStatus">
          <template slot-scope="scope">
            <span v-if="scope.row.reviewStatus === 0">待批阅</span>
            <span v-if="scope.row.reviewStatus === 1">合格</span>
            <span v-if="scope.row.reviewStatus === 2">不合格</span>
          </template>
        </el-table-column>
        <el-table-column
          label="审核人"
          prop="reviewer"
          align="center"
          :show-overflow-tooltip="true"
        />
        <el-table-column
          label="审核时间"
          prop="reviewTime"
          align="center"
          :show-overflow-tooltip="true"
        />
        <el-table-column
          label="操作"
          align="center"
          class-name="small-padding fixed-width"
          fixed="right"
          width="100"
        >
          <template slot-scope="scope">
            <el-button size="mini" type="text" @click="seeTestPaper(scope.row)"
              >查看试卷</el-button
            >
          </template>
        </el-table-column>
      </el-table>

      <pagination
        v-show="total > 0"
        :total="total"
        :page.sync="queryParams.currentPage"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </el-dialog>

    <!-- 生成二维码 -->
    <el-dialog :title="title" :visible.sync="open6" append-to-body>
      <div
        style="
          width: 300px;
          height: 300px;
          border: 1px solid #000000;
          margin: 0 auto;
        "
      ></div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="down">下载</el-button>
      </div>
    </el-dialog>

    <!-- 查看试卷 -->
    <el-dialog
      title="查看试卷"
      :visible.sync="openTestPaper"
      width="700px"
      append-to-body
      @close="closeSee"
    >
      <div class="checktitle">
        <p>总分：{{ examPaper.totalScore }}</p>
        <p>及格分：{{ examPaper.passLine }}</p>
        <p>所得分：{{ examPaper.score }}</p>
      </div>
      <!-- 单选 -->
      <div class="topickinds" v-if="questionList[0].title != ''">
        <p>{{ questionList[0].title }}</p>
        <div class="topic">
          <div
            v-for="item in questionList[0].children"
            :key="item.theid"
            class="topiclist"
          >
            <div>
              {{ item.subject }}
              <el-radio-group class="option" disabled>
                <el-radio
                  v-for="ele in item.options"
                  :key="ele.val"
                  :value="ele.val"
                  :label="ele.val"
                  >{{ ele.val + ele.title }}</el-radio
                >
              </el-radio-group>
            </div>
            <div class="examineekey">考生答案：{{ item.answerSituation }}</div>
            <div class="rightkey">正确答案：{{ item.answer }}</div>
            <div class="rightkeybg" v-if="item.analysis != ''">
              <div class="analysis">试题解析</div>
              {{ item.analysis }}
            </div>
          </div>
        </div>
      </div>
      <!-- 多选 -->
      <div class="topickinds" v-if="questionList[1].title != ''">
        <p>{{ questionList[1].title }}</p>
        <div class="topic">
          <div
            v-for="item in questionList[1].children"
            :key="item.theid"
            class="topiclist"
          >
            <div>
              {{ item.subject }}
              <p class="option">
                <el-checkbox-group disabled>
                  <el-checkbox
                    v-for="ele in item.options"
                    :key="ele.val"
                    :label="ele.val"
                    >{{ ele.val + ele.title }}</el-checkbox
                  >
                </el-checkbox-group>
              </p>
            </div>
            <div class="examineekey">考生答案：{{ item.answerSituation }}</div>
            <div class="rightkey">正确答案：{{ item.answer }}</div>
            <div class="rightkeybg" v-if="item.analysis != ''">
              <div class="analysis">试题解析</div>
              {{ item.analysis }}
            </div>
          </div>
        </div>
      </div>
      <!-- 判断 -->
      <div class="topickinds" v-if="questionList[2].title != ''">
        <p>{{ questionList[2].title }}</p>
        <div class="topic">
          <div
            v-for="item in questionList[2].children"
            :key="item.theid"
            class="topiclist"
          >
            <div>
              {{ item.subject }}
              <el-radio-group class="option" disabled>
                <el-radio
                  v-for="ele in item.options"
                  :key="ele.val"
                  :value="ele.val"
                  :label="ele.val"
                  >{{ ele.val + "、" + ele.title }}</el-radio
                >
              </el-radio-group>
            </div>
            <div class="examineekey">考生答案：{{ item.answerSituation }}</div>
            <div class="rightkey">正确答案：{{ item.answer }}</div>
            <div class="rightkeybg" v-if="item.analysis != ''">
              <div class="analysis">试题解析</div>
              {{ item.analysis }}
            </div>
          </div>
        </div>
      </div>
      <!-- 填空 -->
      <div class="topickinds" v-if="questionList[3].title != ''">
        <p>{{ questionList[3].title }}</p>
        <div class="topic">
          <div
            v-for="item in questionList[3].children"
            :key="item.theid"
            class="topiclist"
          >
            <div>
              {{ item.subject }}
            </div>
            <div class="examineekey">考生答案：{{ item.answerSituation }}</div>
            <div class="rightkey">正确答案：{{ item.answer }}</div>
            <div class="rightkeybg" v-if="item.analysis != ''">
              <div class="analysis">试题解析</div>
              {{ item.analysis }}
            </div>
          </div>
        </div>
      </div>
    </el-dialog>

    <!-- 导出名单 -->
    <el-dialog :title="title" :visible.sync="open7" append-to-body>
      <el-button
        type="warning"
        plain
        icon="el-icon-download"
        size="mini"
        @click="handleExport"
        >导出名单</el-button
      >
      <div
        style="margin-top:30px;margin-bottom:30px;background:#DCDFE6;padding:15px; 0"
      >
        人员名单
      </div>
      <el-form
        ref="form1"
        :model="form1"
        :rules="rules"
        :validate-on-rule-change="false"
        label-width="80px"
      >
        <el-form-item label="培训时间" prop="tableList">
          <el-input v-model="form1.tableList" placeholder="培训时间" />
        </el-form-item>
        <el-form-item label="班组名称" prop="tableList">
          <el-input v-model="form1.tableList" placeholder="班组名称" />
        </el-form-item>
        <el-form-item label="老师" prop="tableList">
          <el-input v-model="form1.tableList" placeholder="老师" />
        </el-form-item>
        <el-form-item label="课程名称" prop="tableList">
          <el-input v-model="form1.tableList" placeholder="课程名称" />
        </el-form-item>
      </el-form>
      <div style="margin-top:30px;background:#DCDFE6;padding:15px; 0">
        名单详情
      </div>
      <el-table v-loading="loading" :data="tableList" :border="true">
        <el-table-column label="工号" prop="userId" align="center" />
        <el-table-column
          label="姓名"
          prop="tableList"
          align="center"
          :show-overflow-tooltip="true"
        />
        <el-table-column
          label="部门"
          prop="tableList"
          align="center"
          el-table-column
        />
        <el-table-column label="签到时间" prop="roleSort" align="center" />
        <el-table-column
          label="签字"
          prop="tableList"
          align="center"
          :show-overflow-tooltip="true"
        ></el-table-column>
      </el-table>
    </el-dialog>

    <!-- 导出成绩表 -->
    <el-dialog :title="title" :visible.sync="open8" append-to-body>
      <el-button
        type="warning"
        plain
        icon="el-icon-download"
        size="mini"
        @click="handleExport"
        >导成绩表</el-button
      >
      <div
        style="margin-top:30px;margin-bottom:30px;background:#DCDFE6;padding:15px; 0"
      >
        个人名单
      </div>
      <el-form
        ref="form2"
        :model="form2"
        :rules="rules"
        :validate-on-rule-change="false"
        label-width="80px"
      >
        <el-form-item label="培训时间" prop="tableList">
          <el-input v-model="form2.tableList" placeholder="培训时间" />
        </el-form-item>
        <el-form-item label="班组机构" prop="tableList">
          <el-input v-model="form2.tableList" placeholder="班组名称" />
        </el-form-item>
        <el-form-item label="培训内容" prop="tableList">
          <el-input v-model="form2.tableList" placeholder="老师" />
        </el-form-item>
        <el-form-item label="培训管理" prop="tableList">
          <el-input v-model="form2.tableList" placeholder="课程名称" />
        </el-form-item>
      </el-form>
      <div style="margin-top:30px;background:#DCDFE6;padding:15px; 0">
        名单详情
      </div>
      <el-table v-loading="loading" :data="tableList" :border="true">
        <el-table-column label="工号" prop="userId" align="center" />
        <el-table-column
          label="姓名"
          prop="tableList"
          align="center"
          :show-overflow-tooltip="true"
        />
        <el-table-column
          label="部门"
          prop="tableList"
          align="center"
          el-table-column
        />
        <el-table-column label="学习时长" prop="tableList" align="center" />
        <el-table-column
          label="考核情况"
          prop="tableList"
          align="center"
          :show-overflow-tooltip="true"
        ></el-table-column>
      </el-table>
    </el-dialog>
  </div>
</template>
<script>
import UploadImage from "@/components/ImageUpload";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
// import { getToken } from "@/utils/auth";
import tableData from "@/assets/json/adminSet.json";
import tableDataDetail from "@/assets/json/adminSetDetail.json";
import tree from "@/assets/json/tree.json";
import dict from "@/assets/json/dict.json";

import {
  getPage,
  listData,
  getSelect,
  getStaffCom,
  getCertificate,
  addData,
  getData,
  updateData,
  changeWorkType,
  changePost,
  delData,
  delMultiData,
  EnableStaff,
  getExamStatistics,
  getCrew,
  getTeam,
  getPaper,
  getAuditask,
} from "@/api/trainAdmin/personTrainNote";

export default {
  name: "personTrainNote",
  data() {
    return {
      Status: 1,
      crewOptions: [],
      checkOpen: false,
      multiCheckOpen: false,
      checkList: ["选中且禁用", "复选框 A"],

      cateOptions: [], // 培训类型

      radio: "1",
      // 开始时间
      valuestater: "",
      // 结束时间
      valueend: "",
      // 日期范围
      dateRange: [],
      // 上传图片
      imageUrl: "",
      // 查询参数
      queryParams: {
        currentPage: 1,
        pageSize: 10,
        keywords: undefined,
        category: undefined, // 培训分类
        trainMode: undefined, // 培训方式
        examMode: undefined, // 考试方式
        trainLevel: undefined, // 培训级别
        trainPlace: undefined, // 培训地点
        department: undefined, // 培训部门
        startTime: undefined, // 开始时间
        endTime: undefined, // 结束时间
        shiftId: undefined, // 培训班组
        trainTaskId: undefined, // 培训任务 id
        releaseStatus: 1, // 发布情况 0-待发布 1-已发布
      },
      // 班组人员
      peoplequeryParams: {
        theid: undefined,
        currentPage: 1,
        pageSize: 10,
        personnelId: undefined, // 人员 id
        trainTaskId: undefined, //培训任务id
        personnelType: undefined, // 参训人员类别 1-内部员工 2-外委人员
      },
      ispeople: "", // 外委 员工 判断
      // 审核列表
      ExamineOptions: [],
      Examinetotal: 0,
      openTestStat: false, //考试统计
      openTeam: false, //培训班组
      // 查看试卷
      openTestPaper: false, //查看试卷
      examPaper: {},
      questionList: [
        { title: "", children: [] },
        { title: "", children: [] },
        { title: "", children: [] },
        { title: "", children: [] },
      ],

      testStatForm: {},
      // 培训审核
      releaseParams: {},

      // 显示搜索条件
      showSearch: true,
      /**功能按钮 */
      // 用户导入参数
      upload: {
        // 是否显示弹出层（用户导入）
        open: false,
        openset: false,
        // 弹出层标题（用户导入）
        title: "",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        // headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        // url: process.env.VUE_APP_BASE_API + "/system/user/importData",
        url: "",
      },
      /**表格展示 */
      // 遮罩层
      loading: true,
      // 表格数据
      tableList: [],
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 总条数
      total: 0,
      crewtotal: 0,
      /** 弹框部分-------- */
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      open3: false,
      open4: false,
      open5: false,
      open6: false,
      open7: false,
      open8: false,
      // 表单参数
      form: {
        titlepop: null,
        userName: null,
        deptId: null,
        phonenumber: null,
        picpop: null,
        roleIds: [],
        centlink: null,
        roleSort: null,
      },
      form1: {
        tableList: null,
      },
      form2: {
        tableList: null,
      },
      // 表单校验
      rules: {
        titlepop: [
          { required: true, message: "标题不能为空", trigger: "blur" },
          {
            min: 2,
            max: 10,
            message: "长度在 2 到 10 个字符",
            trigger: "blur",
          },
        ],
        picpop: [{ required: true, message: "图片不能为空", trigger: "blur" }],
        centlink: [
          { required: true, message: "内容链接不能为空", trigger: "blur" },
        ],
        roleSort: [
          { required: true, message: "序号不能为空", trigger: "blur" },
        ],
        roleIds: [
          // { type:"array",required: true, message: '请至少选择一个角色', trigger: 'change' }
          // { required: true, message: '请至少选择一个角色', trigger: ['blur','change'] }
          { required: true, message: "角色不能为空", trigger: "change" },
        ],
      },
      // 部门树选项
      deptOptions: [],
      // 角色选项
      roleOptions: [],
      // 状态数据字典
      statusOptions: [],
      open2: false,
      loading2: true,
      tableList2: [],
      isexam: "",
      trainingtaskId: "", //  培训任务id
    };
  },
  components: {
    Treeselect,
    UploadImage,
  },
  computed: {
    userInfo() {
      return this.$store.state.userInfo;
    },
    checkNum() {
      //添加人员 选中人数
      return this.ids2.length;
    },
  },
  created() {
    this.getList();
    this.getSelect();
    this.getTeamList();
    /* this.getDicts("sys_normal_disable").then(response => {
      this.statusOptions = response.data;
    }); */

    // 获取所属部门数据 树
    this.dictOptions = tree.data;
    // 获取所有角色数据 数组
    // this.roleOptions = tableDataDetail.swip;
    // 获取角色状态字典
    this.statusOptions = dict.roles;
  },
  mounted() {},
  methods: {
    // 培训时间
    selectTime(val) {
      console.log(!val);
      if (val) {
        this.handleQuery();
      } else {
        this.queryParams.startTime = undefined;
        this.queryParams.endTime = undefined;
        this.handleQuery();
      }
    },
    getList() {
      this.loading = true;
      this.loading2 = true;
      if (this.dateRange != null) {
        this.queryParams.startTime = this.dateRange[0];
        this.queryParams.endTime = this.dateRange[1];
      }
      // 调接口
      listData(this.queryParams).then((response) => {
        // console.log(response);
        this.tableList = response.result.rows;
        this.total = response.result.total;
        this.loading = false;
        this.loading2 = false;
      });
    },
    testStat(row) {
      console.log(row);
      const theId = row.theid;
      getExamStatistics(theId).then((response) => {
        this.testStatForm = response.result[0];
        this.openTestStat = true;
      });
    },
    handleTeam(row) {
      // console.log(row);
      this.isexam = row.examination;
      this.peoplequeryParams.theid = row.theid;
      this.getCrews();
    },
    getCrews() {
      getCrew(this.peoplequeryParams).then((response) => {
        console.log("response", response);
        this.ispeople = response.result.personnelType;
        this.crewOptions = response.result.rows;
        this.crewtotal = response.result.total;
        this.peoplequeryParams.personnelType = response.result.personnelType;
        this.openTeam = true;
      });
    },
    seeTestPaper(row) {
      console.log("查看试卷", row);
      this.peoplequeryParams.personnelId = row.theid;
      this.openTestPaper = true;
      getPaper(this.peoplequeryParams).then((response) => {
        console.log(response);
        this.examPaper = response.result;
        let obj = response.result.questionList;
        let questionList = [
          { title: "", children: [] },
          { title: "", children: [] },
          { title: "", children: [] },
          { title: "", children: [] },
        ];
        Object.keys(obj).forEach((key) => {
          if (
            obj[key].title.indexOf("单选题") != -1 &&
            obj[key].children.length > 0
          ) {
            questionList[0] = obj[key];
          } else if (
            obj[key].title.indexOf("多选题") != -1 &&
            obj[key].children.length > 0
          ) {
            questionList[1] = obj[key];
          } else if (
            obj[key].title.indexOf("判断题") != -1 &&
            obj[key].children.length > 0
          ) {
            questionList[2] = obj[key];
          } else if (
            obj[key].title.indexOf("填空题") != -1 &&
            obj[key].children.length > 0
          ) {
            questionList[3] = obj[key];
          }
        });
        this.questionList = questionList;
        this.questionList.forEach((item) => {
          item.children.forEach((item1) => {
            item1.answer = item1.answer.replace(/\|\|\|/g, " ");
            item1.answerSituation = item1.answerSituation.replace(
              /\|\|\|/g,
              " "
            );
          });
        });
        this.openTestPaper = true;
      });
    },
    // 关闭查看试卷
    closeSee() {
      this.examPaper = {};
      this.questionList = [
        { title: "", children: [] },
        { title: "", children: [] },
        { title: "", children: [] },
        { title: "", children: [] },
      ];
    },
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加";
    },
    handleCheck(row) {
      // console.log("shen", row);
      this.trainingtaskId = row.theid; //消息接收人员名单id列表
      console.log(this.trainingtaskId);
      // this.checkOpen = true;
      this.isexam = row.examination;
      this.peoplequeryParams.theid = row.theid;
      this.getExamine();
    },
    getExamine() {
      getCrew(this.peoplequeryParams).then((response) => {
        console.log("审核", response);
        this.ispeople = response.result.personnelType;
        this.ExamineOptions = response.result.rows;
        this.Examinetotal = response.result.total;
        this.checkOpen = true;
      });
    },
    handleMultiCheck() {
      this.resetRelease();
      const _that = this;
      // this.multiCheckOpen = true
      // this.releaseParams.theids = _that.ids; //消息接收人员名单id列表
      this.releaseParams.trainingtaskId = this.trainingtaskId;
      console.log(this.releaseParams);
      const theIds = this.ids.join(",");
      this.releaseParams.theids = theIds; //消息接收人员名单id列表
      this.$confirm("是否确认审核?", "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(function () {
          // 调接口
          console.log(_that.releaseParams);
          console.log("---", getAuditask(_that.releaseParams));
          return getAuditask(_that.releaseParams);
        })
        .then(() => {
          this.getExamine();
          this.msgSuccess("所选人员，审核成功！！！");
        });
    },
    resetRelease() {
      this.releaseParams = {
        theids: undefined, //消息接收人员名单id列表
        trainingtaskId: undefined, //培训任务 id
        reviewStatus: this.Status, //
        reviewerId: this.userInfo.theid, //发布人id
        reviewer: this.userInfo.thename, //发布人
      };
    },
    /** 登录日志 */
    handleLog(row) {
      const userId = row.userId;
      this.open2 = true;
      this.loading2 = false;
      this.tableList2 = this.tableList;
    },
    /* deptIdChange(val) {
      this.$nextTick(() => {
        this.$refs.form.validateField('deptId');
      })
    }, */
    /** 筛选条件部分------------------- */
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      // if()
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /**  */

    // 考试类型 下拉框
    getSelect() {
      getSelect().then((response) => {
        this.cateOptions = response.result.trainCategory; //培训类型
        // console.log(this.cateOptions);
        // this.levelOptions = response.result.examLevel; //考试级别
        // this.placeOptions = response.result.examPlace; //考试地点
        // this.modeOptions = response.result.examMode; //考试方式
        // this.deptOptions = response.result.department; //考试部门
      });
    },
    // 培训班组下拉
    getTeamList() {
      getTeam(this.queryParams).then((response) => {
        this.deptOptions = response.result.rows;
        // console.log(this.deptOptions);
      });
    },
    /** 表格展示部分------------------- */

    // 导出名单/成绩表
    handleExport() {},
    // 调整时间
    adjustmentTime(row) {
      const userId = row.userId;
      this.open5 = true;
    },
    // 课程显示
    Coursedisplay(row) {
      this.open3 = true;
    },
    // 培训人员显示
    trainingPd(row) {
      this.open4 = true;
    },
    // 生成二维码
    generateCode() {
      this.open6 = true;
    },
    // 导出名单
    exportList() {
      this.open7 = true;
    },
    // 导出成绩表
    exportGradesheet() {
      this.open8 = true;
    },
    /** 功能按钮部分------------------- */
    /** 新增按钮操作 */

    /* 人员设置按钮操作 */
    personnelSetting() {
      this.reset();
      this.openset = true;
      this.title = "人员设置";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      // 调接口 获取对应管理员数据
      var res = tableDataDetail;
      this.form = res.data;
      this.form.roleIds = res.data.roleIds;
      this.open = true;
      this.title = "修改xx";
      /* getRole(userId).then(response => {
            this.form = response.data;
            this.open = true;
            this.title = "修改角色";
        }); */
    },
    // 查看按钮
    /** 取消发布操作 */
    unpublish(row) {
      const userIds = row.userId || this.ids;
      this.$confirm("是否确认取消发布?", "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(function () {
          // 调接口
          // return delRole(userIds);
        })
        .then(() => {
          this.getList();
          this.msgSuccess("取消成功");
        });
    },

    /** 下载模板操作 */
    importTemplate() {
      /* importTemplate().then(response => {
        this.download(response.msg);
      }); */
    },
    // 文件上传中处理
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
    // 文件上传成功处理
    handleFileSuccess(response, file, fileList) {
      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
      this.getList();
    },
    // 提交上传文件
    submitFileForm() {
      this.$refs.upload.submit();
    },
    // 下载二维码
    down() {},
    // 表单重置
    reset() {
      this.form = {
        nickName: null,
        userName: null,
        deptId: null,
        phonenumber: null,
        roleIds: [],
        status: "0",
      };
      // this.resetForm("form");
    },
    /** 弹框部分--------------------- */
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.userId != undefined) {
            /* updateRole(this.form).then(response => {
              this.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            }); */
            this.msgSuccess("修改成功");
            this.open = false;
            this.getList();
          } else {
            /* addRole(this.form).then(response => {
              this.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            }); */
            this.msgSuccess("新增成功");
            this.open = false;
            this.getList();
          }
        }
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 图片上传
    handleAvatarSuccess(res, file) {
      this.imageUrl = URL.createObjectURL(file.raw);
    },
    beforeAvatarUpload(file) {
      const isJPG = file.type === "image/jpeg";
      const isLt2M = file.size / 1024 / 1024 < 2;

      if (!isJPG) {
        this.$message.error("上传头像图片只能是 JPG 格式!");
      }
      if (!isLt2M) {
        this.$message.error("上传头像图片大小不能超过 2MB!");
      }
      return isJPG && isLt2M;
    },

    // 多选框选中数据
    handleSelectionChange(selection) {
      console.log(selection);
      this.ids = selection.map((item) => item.theid);
      // console.log(this.ids);
      this.single = selection.length != 1;
      this.multiple = !selection.length;
    },
  },
};
</script>

<style scoped lang="scss">
// 查看试题
.topickinds {
  margin-bottom: 20px;
  .topic {
    margin-top: 20px;
    .topiclist {
      margin-top: 20px;
      line-height: 20px;
      input {
        border-bottom: 1px solid;
      }
    }
    .option {
      margin-top: 10px;
    }
  }
}
// 查看试卷  禁用之后样式修改
.topickinds .topic .option {
  display: block;
}
/deep/ .el-radio__input.is-disabled + span.el-radio__label {
  color: #606266;
  cursor: not-allowed;
}
/deep/ .el-radio__input.is-disabled .el-radio__inner,
.el-radio__input.is-disabled.is-checked .el-radio__inner {
  background-color: #fff;
  border-color: #dcdfe6;
}
/deep/ .el-checkbox__input.is-disabled + span.el-checkbox__label {
  color: #606266;
  cursor: not-allowed;
}
// 解析样式
.examineekey {
  color: #e12a1a;
  margin-top: 10px;
  font-weight: 600;
  // font-size: 20px;
}
.rightkey {
  color: #0ac23e;
  margin-top: 10px;
  font-weight: 600;
  // font-size: 20px;
}
.rightkeybg {
  /* background: #a9eabb; */
  background: #fbfbfb;
  border: 1px solid #e8e8e8;
  border-radius: 10px;
  padding: 14px 20px;
  margin-top: 10px;
}
// /deep/
// 图片上传
.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.avatar-uploader .el-upload:hover {
  border-color: #409eff;
}
.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  line-height: 178px;
  text-align: center;
}
.avatar {
  width: 178px;
  height: 178px;
  display: block;
}
h3 {
  background: #f1e9c8;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 34px;
  line-height: 34px;
  padding: 0 16px;
  margin-bottom: 10px;
  cursor: pointer;
}
/* .el-date-editor*/
/deep/ .el-dialog__body .el-date-editor.el-input,
/deep/ .el-dialog__body .el-date-editor.el-input__inner {
  // width: 220px;
  width: auto !important;
}

.checktitle {
  width: 100%;
  display: flex;
  font-size: 15px;
  color: red;
  margin-bottom: 20px;
  border-bottom: 1px solid red;
  padding-bottom: 10px;
  p {
    margin-right: 10%;
  }
}
.multiple {
  margin: 0 0 0 20px;
}
.side {
  position: relative;
}
.side /deep/ .el-input {
  width: 48%;
}
.side /deep/ .el-input:last-child {
  position: absolute;
  right: 0;
}
.el-table .active {
  color: #409eff;
  cursor: pointer;
  text-decoration: underline;
}
// 查看试题
.topickinds {
  margin-bottom: 20px;
  .topic {
    margin-top: 20px;
    .topiclist {
      margin-top: 20px;
      input {
        border-bottom: 1px solid;
      }
    }
    .option {
      margin-top: 10px;
    }
  }
}
.judge {
  margin-top: 10px;
}
</style>